package com.masterrabbit.sn.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.masterrabbit.sn.service.ActivitiesService;
import com.masterrabbit.sn.domain.Activities;
import com.masterrabbit.sn.mapper.ActivitiesMapper;
/**
* @author 13119
* @description 针对表【activities】的数据库操作Service实现
* @createDate 2025-03-18 10:00:39
*/
@Service
public class ActivitiesServiceImpl extends ServiceImpl<ActivitiesMapper, Activities>
    implements ActivitiesService {
    @Autowired
    private ActivitiesMapper activitiesMapper;
    /**
     * 添加活动
     * @param activities
     * @return
     */
    @Override
    public int addActivities(Activities activities) {
        return activitiesMapper.insert(activities);
    }
    /**
     * 根据上架情况查询活动
     * @param merchantId
     * @param pageNum
     * @param pageSize
     * @return Page<Activities>
     */
    @Override
    public Page<Activities> getOfflineActivities(Integer merchantId, int pageNum, int pageSize) {
        Page<Activities> page = new Page<>(pageNum, pageSize);
        return baseMapper.selectOfflineActivities(page, merchantId);
    }
    /**
     * 根据上架情况查询活动
     * @param merchantId
     * @param pageNum
     * @param pageSize
     * @return Page<Activities>
     **/
    @Override
    public Page<Activities> getOnlineActivities(Integer merchantId, int pageNum, int pageSize) {
        Page<Activities> page = new Page<>(pageNum, pageSize);
        return baseMapper.selectOnlineActivities(page, merchantId);
    }
    /**
     * 根据活动ID查询活动
     * @param activitiesId
     * @return Activities
     **/
    @Override
    public Activities getActivitiesDetails(Integer activitiesId) {
        return activitiesMapper.selectById(activitiesId);
    }
    /**
     * 删除活动
     * @param activitiesId
     * @return int
     **/
    @Override
    public int deleteActivities(int activitiesId) {
        return activitiesMapper.deleteById(activitiesId);
    }
    /**
     * 上架活动
     * @param activitiesId
     * @return
     */
    @Override
    public int updateActivitiesOnline(int activitiesId) {
        return activitiesMapper.updateOnlineActivities(activitiesId);
    }
    /**
     * 下架活动
     * @param activitiesId
     * @return
     **/
    @Override
    public int updateActivitiesOffline(int activitiesId) {
        return activitiesMapper.updateOfflineActivities(activitiesId);
    }

}




